package com.jiangds.open.check.checker;

import com.jiangds.open.check.Checker;
import java.time.ZoneId;
import java.util.Date;

/**
 * {@link DateChecker}  date校验器
 *
 * @author jiangliang
 * @since 2021/1/7 11:38
 */
public class DateChecker extends AbstractChecker<Integer, Date> {

    public DateChecker(Date target) {
        super(target);
    }

    @Override
    public Checker<Integer, Date> notEmpty() {
        return notNull();
    }

    @Override
    public Checker<Integer, Date> range(Integer min, Integer max) {
        return localDateRangeProcessor(
                t->t.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(),
                min,max);
    }

    @Override
    public Checker<Integer, Date> greater(Date greaterThan) {
        return processor(t->!t.before(greaterThan));
    }

    @Override
    public Checker<Integer, Date> less(Date lessThan) {
        return processor(t->!t.after(lessThan));
    }

    @Override
    public Checker<Integer, Date> in(Date... args) {
        return inProcessor(Date::equals,args);
    }
}
